#
# $Id: Makefile 3478 2012-04-20 10:24:37Z mortens $
#
# (C) Copyright 2012, met.no 
#
# This file is part of the ProRad software system for processing
# radar data
#
# The ProRad software is free software; you can redistribute it
# and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2.1,
# or (at your option) any later version.
#
# ProRad is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProRad; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#

CC      := gcc

#CCFLAGS := -Wall -ggdb -DDEBUG
#CCFLAGS := -Wall -ggdb -DNODAEMON -DNOWATCHDOG -DDEBUG
#CCFLAGS := -Wall -ggdb -DNODAEMON -DNOWATCHDOG -DNO_MOM_ANN
#CCFLAGS := -Wall -ggdb -DNODAEMON -DNOWATCHDOG
#CCFLAGS := -Wall -ggdb
CCFLAGS := -Wall

#CCFLAGS += -DZXML

ARFLAGS := r

LFLAGS  := -lmomprorad -lproradmsg -lproradmsg-support -lproradie\
	-lxmlsupport -lxml2 -lz  -lssl -lm\
	-lbase64 -lprorad_radarprod_meta -lprorad_xmlprod_rw


#LIBS    := -L. -L../lib
LIBS    := -L. -L../lib -L../libimportexport

#INCL    := -I. -I../include -I/usr/include/libxml2
INCL    := -I. -I../include -I/usr/include/libxml2 -I../libimportexport


# Opts for command line parsing
#
FILEGGO := cmdline.ggo
SRCGGO  := ${FILEGGO:.ggo=.c}
OBJSGGO := ${FILEGGO:.ggo=.o}
HEADGGO := ${FILEGGO:.ggo=.h}


BINSRC  := prorad-import-module.c
BIN     := ${BINSRC:.c=}

OBJS    := ${OBJSGGO}\
	prorad-import-loop.o\
	read-import-config.o\
	prorad-import-init.o\
	handle-import-connection.o\
	prorad-import-login.o\
	prorad-import-store.o\
	prorad-import-announce-mom.o


OBJSH   := ${OBJS:.o=.h}



.SUFFIXES :
.SUFFIXES : .c .o .a

.c.o:
	${CC} ${CCFLAGS} -fpic ${INCL} -c $< -o $@


${BIN}: ${BINSRC} ${OBJS} ${OBJSH}
	${CC} ${CCFLAGS} ${INCL} -o $@ $< ${OBJS} ${LIBS} ${LFLAGS}


test: test.c ${OBJS} ${OBJSH}
	${CC} ${CCFLAGS} ${INCL} -o $@ $< ${OBJS} ${LIBS} ${LFLAGS}

test2: test2.c ${OBJS} ${OBJSH}
	${CC} ${CCFLAGS} ${INCL} -o $@ $< ${OBJS} ${LIBS} ${LFLAGS}

#
# command line parser tool

${SRCGGO}: ${FILEGGO}
	gengetopt -u --file-name=cmdline --input ${FILEGGO}

install: ${BIN}
	install -v -p -m 755 ${BIN} ../bin

clean:
	rm -f core core.* *~
	rm -f *.a
	rm -f ${BIN} test test2
	rm -f ${SRCGGO} ${HEADGGO} ${OBJS}


